﻿import { createRouter, createWebHistory } from 'vue-router'
import { useUserStore } from '@/stores/user'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      redirect: '/dashboard'
    },
    {
      path: '/dashboard',
      name: 'dashboard',
      component: () => import('../views/Dashboard.vue'),
      meta: { 
        title: '仪表盘'
      }
    },
    // 库存管理
    {
      path: '/inventory',
      redirect: '/inventory/overview'
    },
    {
      path: '/inventory/overview',
      name: 'inventory-overview',
      component: () => import('../views/inventory/Overview.vue'),
      meta: { 
        title: '库存总览'
      }
    },
    {
      path: '/inventory/items',
      name: 'inventory-items',
      component: () => import('../views/inventory/Items.vue'),
      meta: { 
        title: '商品管理'
      }
    },
    {
      path: '/inventory/locations',
      name: 'inventory-locations',
      component: () => import('../views/inventory/Locations.vue'),
      meta: { 
        title: '库位管理'
      }
    },
    {
      path: '/inventory/stock',
      name: 'inventory-stock',
      component: () => import('../views/inventory/Stock.vue'),
      meta: { 
        title: '库存查询'
      }
    },
    // 仓库管理
    {
      path: '/warehouse',
      redirect: '/warehouse/zones'
    },
    {
      path: '/warehouse/zones',
      name: 'warehouse-zones',
      component: () => import('../views/warehouse/Zones.vue'),
      meta: { 
        title: '库区管理'
      }
    },
    {
      path: '/warehouse/racks',
      name: 'warehouse-racks',
      component: () => import('../views/warehouse/Racks.vue'),
      meta: { 
        title: '货架管理'
      }
    },
    {
      path: '/warehouse/areas',
      name: 'warehouse-areas',
      component: () => import('../views/warehouse/Areas.vue'),
      meta: { 
        title: '区域管理'
      }
    },
    // 入库管理
    {
      path: '/inbound',
      redirect: '/inbound/orders'
    },
    {
      path: '/inbound/orders',
      name: 'inbound-orders',
      component: () => import('../views/inbound/Orders.vue'),
      meta: { 
        title: '入库单'
      }
    },
    {
      path: '/inbound/receiving',
      name: 'inbound-receiving',
      component: () => import('../views/inbound/Receiving.vue'),
      meta: { 
        title: '收货管理'
      }
    },
    {
      path: '/inbound/putaway',
      name: 'inbound-putaway',
      component: () => import('../views/inbound/Putaway.vue'),
      meta: { 
        title: '上架管理'
      }
    },
    // 出库管理
    {
      path: '/outbound',
      redirect: '/outbound/orders'
    },
    {
      path: '/outbound/orders',
      name: 'outbound-orders',
      component: () => import('../views/outbound/Orders.vue'),
      meta: { 
        title: '出库单'
      }
    },
    {
      path: '/outbound/picking',
      name: 'outbound-picking',
      component: () => import('../views/outbound/Picking.vue'),
      meta: { 
        title: '拣货管理'
      }
    },
    {
      path: '/outbound/shipping',
      name: 'outbound-shipping',
      component: () => import('../views/outbound/Shipping.vue'),
      meta: { 
        title: '发货管理'
      }
    },
    // 作业管理
    {
      path: '/operations',
      redirect: '/operations/tasks'
    },
    {
      path: '/operations/tasks',
      name: 'operations-tasks',
      component: () => import('../views/operations/Tasks.vue'),
      meta: { 
        title: '任务管理'
      }
    },
    {
      path: '/operations/movements',
      name: 'operations-movements',
      component: () => import('../views/operations/Movements.vue'),
      meta: { 
        title: '移库管理'
      }
    },
    {
      path: '/operations/cycle-count',
      name: 'operations-cycle-count',
      component: () => import('../views/operations/CycleCount.vue'),
      meta: { 
        title: '盘点管理'
      }
    },
    // 报表统计
    {
      path: '/reports',
      redirect: '/reports/inventory'
    },
    {
      path: '/reports/inventory',
      name: 'reports-inventory',
      component: () => import('../views/reports/Inventory.vue'),
      meta: { 
        title: '库存报表'
      }
    },
    {
      path: '/reports/operations',
      name: 'reports-operations',
      component: () => import('../views/reports/Operations.vue'),
      meta: { 
        title: '作业报表'
      }
    },
    {
      path: '/reports/performance',
      name: 'reports-performance',
      component: () => import('../views/reports/Performance.vue'),
      meta: { 
        title: '绩效报表'
      }
    },
    // 承运商管理
    {
      path: '/carrier',
      redirect: '/carrier/management'
    },
    {
      path: '/carrier/management',
      name: 'carrier-management',
      component: () => import('../views/carrier/Management.vue'),
      meta: { 
        title: '承运商管理',
        requiresAuth: true 
      }
    },
    // 系统设置
    {
      path: '/settings',
      name: 'settings',
      component: () => import('../views/Settings.vue'),
      meta: { 
        title: '系统设置'
      }
    }
  ],
})

export default router

